//
//  ShellNodeCell.m
//  ShellWallert
//
//  Created by lvzhao on 2019/10/24.
//  Copyright © 2019 VV. All rights reserved.
//

#import "ShellNodeCell.h"
#import "ShellNodeModel.h"

@interface ShellNodeCell()
//背景
@property (nonatomic,strong) UIView *bgView;

//等级
@property (nonatomic,strong) UILabel *levelLab;
//直属节点
@property (nonatomic,strong) UILabel *ownBrokerLab;

//所有节点算力
@property (nonatomic,strong) UILabel *allHashRateLab;
//矿池奖励
@property (nonatomic,strong) UILabel *rewardLab;

@end

@implementation ShellNodeCell
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.backgroundColor = UIColorHex(0x04172A);
        [self setupView];
    }
    return self;
}


#pragma mark - setupView
- (void)setupView{
    
    
   [self.contentView addSubview:self.bgView];
    [self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(15);
        make.right.mas_equalTo(-15);
        make.height.mas_equalTo(50);
        make.top.mas_equalTo(0);
    }];
    self.bgView.cornerRadius = 4;
    
    //等级
   [self.contentView addSubview:self.levelLab];
   [self.levelLab mas_makeConstraints:^(MASConstraintMaker *make) {
      make.centerY.mas_equalTo(self.contentView.mas_centerY);
      make.left.mas_equalTo(22);
      make.width.mas_equalTo(40);
      make.height.mas_equalTo(self.contentView);
   }];
    
    
    
    //直属节点
     [self.contentView addSubview:self.ownBrokerLab];
     [self.ownBrokerLab mas_makeConstraints:^(MASConstraintMaker *make) {
         make.centerY.mas_equalTo(self.contentView.mas_centerY);
         make.left.mas_equalTo(70);
         make.width.mas_equalTo(50);
         make.height.mas_equalTo(self.contentView);
     }];
    
  
    
   //所有节点算力
   [self.contentView addSubview:self.allHashRateLab];
   [self.allHashRateLab mas_makeConstraints:^(MASConstraintMaker *make) {
       make.centerY.mas_equalTo(self.contentView.mas_centerY);
       make.left.mas_equalTo(130);
       make.width.mas_equalTo(80);
       make.height.mas_equalTo(self.contentView);
   }];

    
      //奖励
      [self.contentView addSubview:self.rewardLab];
      [self.rewardLab mas_makeConstraints:^(MASConstraintMaker *make) {
          make.centerY.mas_equalTo(self.contentView.mas_centerY);
          make.left.mas_equalTo(220);
          make.width.mas_equalTo(K_SCREENWIDTH - 22 - 220);
          make.height.mas_equalTo(self.contentView);
      }];
}


#pragma mark - actions

#pragma mark - custool

#pragma mark - get && set
- (void)setModelObject:(id)modelObject{
    ShellNodeModel *nodeModel = modelObject;

    if(self.indexPath.row % 2 == 0){
        self.bgView.backgroundColor = UIColorHex(0x08233F);
    } else {
        self.backgroundColor = UIColorHex(0x04172A);
    }

    self.levelLab.text = nodeModel.levelDesc;
    self.ownBrokerLab.text = (nodeModel.ownBroker.length == 0)? @"--":nodeModel.ownBroker;
    self.allHashRateLab.text =(nodeModel.allHashRate.length == 0)? @"--":nodeModel.allHashRate;
    self.rewardLab.text = nodeModel.award;

}


- (UIView *)bgView{
    if(!_bgView){
        _bgView = [[UIView alloc] init];
    }
    return _bgView;
}

//等级
- (UILabel *)levelLab{
    if(!_levelLab){
        _levelLab = [UILabel lz_createLabWithTextColor:UIColorHex(0x678DA8) font:k_textFont(13)];
    }
    return _levelLab;
}

//直属节点
- (UILabel *)ownBrokerLab{
    if(!_ownBrokerLab){
        _ownBrokerLab = [UILabel lz_createLabWithTextColor:UIColorHex(0xFFFFFF) font:k_textFont(13)];
    }
    return _ownBrokerLab;
}

//所有节点
- (UILabel *)allHashRateLab{
    if(!_allHashRateLab){
        _allHashRateLab = [UILabel lz_createLabWithTextColor:UIColorHex(0xFFFFFF) font:k_textFont(13)];
    }
    return _allHashRateLab;
}


//奖励
- (UILabel *)rewardLab{
    if(!_rewardLab){
        _rewardLab = [UILabel lz_createLabWithTextColor:UIColorHex(0xFFFFFF) font:k_textFont(13)];
        _rewardLab.numberOfLines = 0;
        _rewardLab.adjustsFontSizeToFitWidth = YES;
        [_rewardLab lz_rightAlignment];

    }
    return _rewardLab;
}@end
